import Vue from "vue";
import VueRouter from "vue-router";
import Home from '@/pages/Home'
import Login from '@/pages/Login'
import Register from '@/pages/Register'
import Search from '@/pages/Search' 
import Test from '@/pages/Test'
Vue.use(VueRouter)

// 解决search重复点击报错的问题
let originPush = VueRouter.prototype.push;
// 不能用箭头函数
VueRouter.prototype.push =function(location,okCallback,errCallback){
    if(okCallback || errCallback){
        return originPush.call(this,location,okCallback,errCallback)
    }else{
        return originPush.call(this,location).catch(()=>{})
    }
}

export default new VueRouter({
    mode:'history',
    routes:[
        {
            path:'/',
            component:Home
        },
        {
            path:'/login',
            component:Login,
            meta:{
                isHiddenShow:true
            }
        },
        {
            path:'/register',
            component:Register,
            meta:{
                isHiddenShow:true
            }
        },
        {
            path:'/search',
            component:Search
        },
        {
            path:'/test',
            component:Test
        },
    ]
})